//
//  AppHelper.m
//
//  Created by xm on 2025/6/20.
//

#import "AppHelper.h"

@implementation AppHelper

+ (NSString *)hexStringFromData:(NSData *)data
{
    const unsigned char *dataBuffer = (const unsigned char *)[data bytes];
    
    if (!dataBuffer) {
        return [NSString string];
    }
    
    NSUInteger dataLength = [data length];
    NSMutableString *hexString = [NSMutableString stringWithCapacity:(dataLength * 2)];
    
    for (int i = 0; i < dataLength; ++i) {
        [hexString appendFormat:@"%02x", dataBuffer[i]];
    }
    
    return [NSString stringWithString:hexString];
}

+ (NSString *)getStringByString:(nullable NSString*)str
{
    if (str == nil || [str isKindOfClass:[NSNull class]] || [str isEqualToString:@"(null)"]) {
        return @"";
    }else
        return str;
}

@end
